﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsAppTest.Class;
using WinFormsAppTest.pojo;

namespace WinFormsAppTest
{
    internal class PancelClass
    {
        public PancelClass() { }
        public DataGridView Test_Table_Files(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 6; i++)
            {
                if(i==5)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "档案编号";
            table.Columns[1].HeaderText = "员工基本信息";
            table.Columns[2].HeaderText = "户口情况";
            table.Columns[3].HeaderText = "合同管理";
            table.Columns[4].HeaderText = "投保情况";
            table.Columns[5].HeaderText = "操作";

            table.Columns[0].Name = "档案编号";
            table.Columns[1].Name = "员工基本信息";
            table.Columns[2].Name = "户口情况";
            table.Columns[3].Name = "合同管理";
            table.Columns[4].Name = "投保情况";
            table.Columns[5].Name = "操作";

            //开始添加数据
            UserService userservice = new UserService();

            List<Files> files = new List<Files>();
            files = userservice.GetUserFiles(id);

            int _i = files.Count-1;
            if (files.Count == 0)
            {
                MessageBox.Show("档案信息无法查询!");
                return table;
            }
            while(files.Count >0)
            {
                //MessageBox.Show(""+files.Count); 
                Files f = files[_i--];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["档案编号"].Value = f.fileid;
                table.Rows[myNewRowIndex].Cells["员工基本信息"].Value = f.msg;
                table.Rows[myNewRowIndex].Cells["户口情况"].Value = f.house;
                table.Rows[myNewRowIndex].Cells["合同管理"].Value = f.contract;
                table.Rows[myNewRowIndex].Cells["投保情况"].Value = f.insure;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.userid;
                files.Remove(f);
            }
            return table;
        }



        public DataGridView Test_Table_Change(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 4; i++)
            {
                if (i == 3)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "变动编号";
            table.Columns[1].HeaderText = "变动类型";
            table.Columns[2].HeaderText = "变动时间";
            table.Columns[3].HeaderText = "操作";

            table.Columns[0].Name = "变动编号";
            table.Columns[1].Name = "变动类型";
            table.Columns[2].Name = "变动时间";
            table.Columns[3].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Change> change = new List<Change>();
            change = userservice.GetUserChange(id);

            int _i = change.Count - 1;
            if (change.Count == 0)
            {
                MessageBox.Show("变动信息无法查询!");
                return table;
            }
            ////
            //while (change.Count > 0)
            //{
            //    //MessageBox.Show(""+files.Count); 
            //    Change f = change[_i--];
            //    int myNewRowIndex = table.Rows.Add();
            //    table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
            //    table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
            //    table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
            //    table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            //    change.Remove(f);
            //}
            ////
            //升序版
            for(int j=0;j<change.Count;j++)
            {
                Change f = change[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
                table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
                table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }

        //用户考核奖惩表
        public DataGridView Test_Table_Exam(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 5; i++)
            {
                if (i == 4)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "考核编号";
            table.Columns[1].HeaderText = "奖惩情况";
            table.Columns[2].HeaderText = "奖惩措施";
            table.Columns[3].HeaderText = "考核目标";
            table.Columns[4].HeaderText = "操作";

            table.Columns[0].Name = "考核编号";
            table.Columns[1].Name = "奖惩情况";
            table.Columns[2].Name = "奖惩措施";
            table.Columns[3].Name = "考核目标";
            table.Columns[4].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Exam> exam = new List<Exam>();
            exam = userservice.GetUserExam(id);

            int _i = exam.Count - 1;
            if (exam.Count == 0)
            {
                MessageBox.Show("考核信息无法查询!");
                return table;
            }
            ////
            //while (change.Count > 0)
            //{
            //    //MessageBox.Show(""+files.Count); 
            //    Change f = change[_i--];
            //    int myNewRowIndex = table.Rows.Add();
            //    table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
            //    table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
            //    table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
            //    table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            //    change.Remove(f);
            //}
            ////
            //升序版
            for (int j = 0; j < exam.Count; j++)
            {
                Exam f = exam[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["考核编号"].Value = f.Examid;
                table.Rows[myNewRowIndex].Cells["奖惩情况"].Value = f.State;
                table.Rows[myNewRowIndex].Cells["奖惩措施"].Value = f.Measure;
                table.Rows[myNewRowIndex].Cells["考核目标"].Value = f.Goal;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }

        //用户考勤表
        public DataGridView Test_Table_Work(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 2; i++)
            {
                if (i == 1)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "考勤编号";
            table.Columns[1].HeaderText = "操作";

            table.Columns[0].Name = "考勤编号";
            table.Columns[1].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Work> work = new List<Work>();
            work = userservice.GetUserWork(id);

            int _i = work.Count - 1;
            if (work.Count == 0)
            {
                MessageBox.Show("考勤信息无法查询!");
                return table;
            }
            //升序版
            for (int j = 0; j < work.Count; j++)
            {
                Work f = work[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["考勤编号"].Value = f.Workid;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }

        //用户考核签到表
        public DataGridView Test_Table_Signs(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 5; i++)
            {
                if (i == 4)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "签到编号";
            table.Columns[1].HeaderText = "签到时间";
            table.Columns[2].HeaderText = "签退时间";
            table.Columns[3].HeaderText = "考勤编号";
            table.Columns[4].HeaderText = "操作";

            table.Columns[0].Name = "签到编号";
            table.Columns[1].Name = "签到时间";
            table.Columns[2].Name = "签退时间";
            table.Columns[3].Name = "考勤编号";
            table.Columns[4].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Signs> signs = new List<Signs>();
            signs = userservice.GetUserSigns(id);

            int _i = signs.Count - 1;
            if (signs.Count == 0)
            {
                MessageBox.Show("考核签到信息无法查询!");
                return table;
            }
            ////
            //while (change.Count > 0)
            //{
            //    //MessageBox.Show(""+files.Count); 
            //    Change f = change[_i--];
            //    int myNewRowIndex = table.Rows.Add();
            //    table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
            //    table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
            //    table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
            //    table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            //    change.Remove(f);
            //}
            ////
            //升序版
            for (int j = 0; j < signs.Count; j++)
            {
                Signs f = signs[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["签到编号"].Value = f.Signid;
                table.Rows[myNewRowIndex].Cells["签到时间"].Value = f.Begintime;
                table.Rows[myNewRowIndex].Cells["签退时间"].Value = f.Endtime;
                table.Rows[myNewRowIndex].Cells["考勤编号"].Value = f.Workid;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }

        //用户考核加班表
        public DataGridView Test_Table_Overtime(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 5; i++)
            {
                if (i == 4)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "加班编号";
            table.Columns[1].HeaderText = "加班开始时间";
            table.Columns[2].HeaderText = "加班结束时间";
            table.Columns[3].HeaderText = "考勤编号";
            table.Columns[4].HeaderText = "操作";

            table.Columns[0].Name = "加班编号";
            table.Columns[1].Name = "加班开始时间";
            table.Columns[2].Name = "加班结束时间";
            table.Columns[3].Name = "考勤编号";
            table.Columns[4].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Overtime> overtime = new List<Overtime>();
            overtime = userservice.GetUserOvertime(id);

            int _i = overtime.Count - 1;
            if (overtime.Count == 0)
            {
                MessageBox.Show("考核加班信息无法查询!");
                return table;
            }
            ////
            //while (change.Count > 0)
            //{
            //    //MessageBox.Show(""+files.Count); 
            //    Change f = change[_i--];
            //    int myNewRowIndex = table.Rows.Add();
            //    table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
            //    table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
            //    table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
            //    table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            //    change.Remove(f);
            //}
            ////
            //升序版
            for (int j = 0; j < overtime.Count; j++)
            {
                Overtime f = overtime[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["加班编号"].Value = f.Overid;
                table.Rows[myNewRowIndex].Cells["加班开始时间"].Value = f.Begintime;
                table.Rows[myNewRowIndex].Cells["加班结束时间"].Value = f.Endtime;
                table.Rows[myNewRowIndex].Cells["考勤编号"].Value = f.Workid;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }


        //用户考核出差表
        public DataGridView Test_Table_Outtime(int id)
        {
            DataGridView table = new DataGridView();
            table.Dock = DockStyle.Fill;
            for (int i = 0; i < 6; i++)
            {
                if (i == 5)
                {
                    table.Columns.Add(new DataGridViewButtonColumn());
                    continue;
                }
                table.Columns.Add(new DataGridViewTextBoxColumn());
            }
            table.Columns[0].HeaderText = "出差编号";
            table.Columns[1].HeaderText = "出差开始时间";
            table.Columns[2].HeaderText = "出差结束时间";
            table.Columns[3].HeaderText = "出差地点";
            table.Columns[4].HeaderText = "考勤编号";
            table.Columns[5].HeaderText = "操作";

            table.Columns[0].Name = "出差编号";
            table.Columns[1].Name = "出差开始时间";
            table.Columns[2].Name = "出差结束时间";
            table.Columns[3].Name = "出差地点";
            table.Columns[4].Name = "考勤编号";
            table.Columns[5].Name = "操作";


            table.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            table.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //table.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //table.Columns[2].Width = 300;

            //开始添加数据
            UserService userservice = new UserService();

            List<Outtime> outtime = new List<Outtime>();
            outtime = userservice.GetUserOuttime(id);

            int _i = outtime.Count - 1;
            if (outtime.Count == 0)
            {
                MessageBox.Show("出差信息无法查询!");
                return table;
            }
            ////
            //while (change.Count > 0)
            //{
            //    //MessageBox.Show(""+files.Count); 
            //    Change f = change[_i--];
            //    int myNewRowIndex = table.Rows.Add();
            //    table.Rows[myNewRowIndex].Cells["变动编号"].Value = f.Changeid;
            //    table.Rows[myNewRowIndex].Cells["变动类型"].Value = f.Type;
            //    table.Rows[myNewRowIndex].Cells["变动时间"].Value = f.Time;
            //    table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            //    change.Remove(f);
            //}
            ////
            //升序版
            for (int j = 0; j < outtime.Count; j++)
            {
                Outtime f = outtime[j];
                int myNewRowIndex = table.Rows.Add();
                table.Rows[myNewRowIndex].Cells["出差编号"].Value = f.Outid;
                table.Rows[myNewRowIndex].Cells["出差开始时间"].Value = f.Begintime;
                table.Rows[myNewRowIndex].Cells["出差结束时间"].Value = f.Endtime;
                table.Rows[myNewRowIndex].Cells["出差地点"].Value = f.Place;
                table.Rows[myNewRowIndex].Cells["考勤编号"].Value = f.Workid;
                table.Rows[myNewRowIndex].Cells["操作"].Value = f.Userid;
            }
            //
            return table;
        }
    }
}
